<div class="page-container" v-cloak>
    <el-card>

        <template #header>
            <div class="breadcrumb" style=" overflow: hidden;">
                <el-breadcrumb separator="/" style=" float: left;  ">
                    <el-breadcrumb-item><a href="{:url('admin/tiktok/index')}">抖音配置</a></el-breadcrumb-item>
                </el-breadcrumb>
                <el-breadcrumb separator="/" style=" float: right;  ">
                    <el-button type="primary" @click="refresh()">刷新</el-button>
                </el-breadcrumb>
            </div>
        </template>
        <div>
            <el-form :inline="true">
                <el-form-item>
                    <el-select filterable v-model="where.store_id" placeholder="所属门店">
                        <el-option label="不限" :value="0"></el-option>
                        <el-option v-for="(item,index) in storelist" :value="index" :key="index"
                                   :label="item"></el-option>
                    </el-select>
                </el-form-item>


                <el-form-item>
                    <el-link>
                        <el-button type="primary" @click="searchEvent">查询</el-button>
                    </el-link>
                    <el-link v-if="{$add} === 1" href="{:url('admin/tiktok/edit')}">
                        <el-button type="primary">新增</el-button>
                    </el-link>
                </el-form-item>
            </el-form>
        </div>
        <div>
            <el-table

                    :data="data_list"
                    style="width: 100%">
                <el-table-column
                        prop="tiktok_id"
                        label="ID"
                        min-width="40">
                </el-table-column>
                <el-table-column label="店铺名称" min-width="100">
                    <template v-slot:default="scope">

                        <span style="color: #529b2e">{{scope.row.store_id}}:{{scope.row.store_name}}</span>
                    </template>
                </el-table-column>

                <el-table-column
                        prop="client_key"
                        label="KEY"
                        min-width="70">
                </el-table-column>
                <el-table-column
                        prop="client_secret"
                        label="秘钥"
                        min-width="100">
                </el-table-column>
                <el-table-column
                        prop="poi_id"
                        min-width="70"
                        label="抖音来客门店ID">
                </el-table-column>
                <el-table-column
                        align="center"
                        min-width="180"
                        label="操作">
                    <template #default="{row}">
                        <el-link :href="'{:url('admin/tiktok/edit')}?tiktok_id='+row.tiktok_id">
                            <el-button type="primary">编辑</el-button>
                        </el-link>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        background
                        layout="prev, pager, next"
                        :total="total_num"
                        :current-page="current_page"
                        :page-size="per_page"
                        @current-change="currentChangeEvent"
                >
                </el-pagination>
            </div>
        </div>
    </el-card>
</div>

<script>
    const App = {
        data() {
            return {
                is_init_list: true,
                storelist: [],
                where: {},
                value1: '',
                isadmin: 0
            }
        },
        methods: {
            GetList() {
                this.httpGet("{:url('admin/tiktok/index/lists')}", {
                    page: this.current_page,
                    ...this.where
                }).then(res => {
                    let {lists = {}, storelist = [], isadmin = ''} = res.data
                    this.storelist = storelist
                    this.isadmin = isadmin
                    this.handRes(lists)
                })
            },
            refundorder(order_id) {
                this.$confirm('是否取消订单并退款？', '提示').then(() => {
                    this.httpGet("{:url('admin/tiktok/refundorder?order_id=')}" + order_id, {}).then(res => {
                        if (res.status) {
                            this.$message.success(res.msg)
                            this.GetList()
                        }
                    })
                }).catch(err => {
                })
            },
            cancelorder(order_id) {
                this.$confirm('是否取消订单不退款？', '提示').then(() => {
                    this.httpGet("{:url('admin/tiktok/cancelorder?order_id=')}" + order_id, {}).then(res => {
                        if (res.status) {
                            this.$message.success(res.msg)
                            this.GetList()
                        }
                    })
                }).catch(err => {
                })
            },
            searchEvent() {
                this.GetList()
            }
        }
    }
</script>